//调用js浮层
var pageUserAdd = null;
$('#k_add').live('click', function() {
	pageUserAdd = $.layer({
		type: 1,
		title: false,
		area: ['580', 'auto'],
		border: [0],
		shade: [0.3, '#000'],
		closeBtn: [0, false],
		fadeIn: 500,
		move: ".key_layer .tit",
		page: {
			dom: '.key_layer'
		}
	});
	//自设关闭
	$('.key_layer > .closeBtn,.key_layer .cancelLayer').live('click', function() {
		layer.close(pageUserAdd);		
		$("#addkeyGroName").attr("value","");
		$("#addkeyGroName").text("");
		$(".clearFormInput").val("");
		$("#singlePortAdd").val("1");
		$("#singlePortAddText").text("是");
		$(".boxPosition").removeClass("checked");
	});
	//	$('#addParameterArea').validationEngine('validate');
	avoidDup = true;
});

var pageUserEdit = null;
$('.revise').live('click', function() {
	pageUserEdit = $.layer({
		type: 1,
		title: false,
		area: ['580', 'auto'],
		border: [0],
		shade: [0.3, '#000'],
		closeBtn: [0, false],
		fadeIn: 500,
		move: ".key_layerEdit .tit",
		page: {
			dom: '.key_layerEdit'
		}
	});

	//自设关闭
	$('.key_layerEdit > .closeBtn,.key_layerEdit .cancelLayer').live('click', function() {
		layer.close(pageUserEdit);
		$("#userPwdEditText").val("");
	});

	var userName = $(this).attr("userName").trim();
	$("#userNameEditText").val(userName);
	
	var userAccount = $(this).attr("userAccount").trim();
	$("#userAccountEditText").val(userAccount);
	
	var userPhone = $(this).attr("userPhone").trim();
	$("#userPhoneEditText").val(userPhone);
	
	var userMailbox = $(this).attr("userMailbox").trim();
	$("#userMailboxEditText").val(userMailbox);
	
//	$("#userPwdEditText").val("******");
	var group = $(this).attr("groupName").trim();
	$("#eidkeyGroName").val(group);

	var groupId = $(this).attr("groupId").trim();
	$("#userGroupId").val(groupId);
	$("#userGroupIdS").val(groupId);

	var userId = $(this).attr("userId").trim();
	$("#userId").val(userId);

	var singleLogin = $(this).attr("singleLogin").trim();
	$("#singlePortEdit").val(singleLogin);
	if($("#singlePortEdit").val() == 1) {
		$("#singlePortEditText").text("是")
	} else {
		$("#singlePortEditText").text("否")
	}
	/**
	 * app为选择app端的元素对象
	 * web为选择web端的元素对象
	 * objV为当前点击事件对象的属性名
	 */
	
	function appWebEdit(app,web,objAttr,objCur){
		var objVal = objCur.attr(objAttr);
		if(objVal==0){
			app.addClass("checked");
			web.removeClass("checked");
		}else if(objVal==1){
			app.removeClass("checked");
			web.addClass("checked");
		}else if(objVal==2){
			app.addClass("checked");
			web.addClass("checked");
		}
	}
	var obj = $(this);
	appWebEdit($("#loginAppPortEdit"),$("#loginWebPortEdit"),"loginPlatforn",obj);
	appWebEdit($("#ifmAppPortEdit"),$("#ifmWebPortEdit"),"infoManage",obj);
	appWebEdit($("#userAppPortEdit"),$("#userWebPortEdit"),"userManage",obj);
});

var q = {
	//采集预警
	"loadData": function(data) {
		var objCount = data.returnData.length; //取得组织用户列表
		$("#curLen").val(objCount);
		var htmlList = "", msgRight = "", msgRightIds = "", modelId = "", modelName = "";
		var modelIdsArr = [],modelIdArr = [],modelNameArr = [],cycleIdArr = [];
		for(var i = 0; i < objCount; i++) {
			var groupName = data.returnData[i].groupName;
			var groupId = data.returnData[i].groupId;
			var userId = data.returnData[i].userId;
			var userName = data.returnData[i].userAccount;
			var userNameone = data.returnData[i].userName;
			var userPhone = data.returnData[i].userPhone||"";
			var userMailbox = data.returnData[i].userMailbox||"";
			var singleLogin = data.returnData[i].singleLogin;
			var loginPlatforn = data.returnData[i].loginPlatforn;
			var infoManage = data.returnData[i].infoManage;
			var userManage = data.returnData[i].userManage;
			var userType = data.returnData[i].userType;
			var modelIds = data.returnData[i].modelId;
			if(modelIds){
				modelIdsArr = modelIds.split(",");
				modelIdArr = [],modelNameArr = [],cycleIdArr = [];
				for(var j=0;j<modelIdsArr.length;j++){
					modelIdArr.push(modelIdsArr[j].split("|")[0]);
					modelNameArr.push(modelIdsArr[j].split("|")[1]);
					cycleIdArr.push(modelIdsArr[j].split("|")[2]);
				}
				modelId = modelIdArr.join(",");
				modelName = modelNameArr.join(",");
				cycleId = cycleIdArr.join(",");
			}else{
				modelId = "";
				modelName = "";
				cycleId = "";
			}
			msgRightIds = data.returnData[i].ropeProgramme;
			if(msgRightIds != null) { 
				var msgRightId = msgRightIds.split(",");
				for(var k = 0; k < msgRightId.length; k++) {
					if(data.returnData[objCount - 1].ifmInfo != null) {
						for(var m = 0; m < data.returnData[objCount - 1].ifmInfo.length; m++) {
							if(msgRightId[k] == data.returnData[objCount - 1].ifmInfo[m].ifmId) {
								msgRight += data.returnData[objCount - 1].ifmInfo[m].ifmName + ",";
							}
						}
					}
				}
			}else{
				msgRightIds = "";
			}
			msgRight = msgRight.substring(0, msgRight.length - 1);
			if(userName != null) {
				htmlList = htmlList + '<tr class="td"><td><span title='+groupName+'>' + groupName + 
							'</span></td><td><span title='+userName+'>' + userName + 
							'</span></td><td><span title='+userNameone+'>' + userNameone + 
							'</span></td><td><span title='+userPhone+'>' + userPhone + 
							'</span></td><td><span title='+userMailbox+'>' + userMailbox + 
							'</span></td><td colspan="3"><span title='+msgRight+'>' + msgRight + 
							'</span></td><td colspan="1"><a href="javascript:void(0);" data-url="userPramEdit.jsp?ifm_id=' + msgRightIds + 
							'&userId=' + userId + '&userName=' + userName + ' &groupId=' + groupId +' &groupName=' + groupName + 
							' " class="green openF">编辑</a></td><td colspan="3"><span title='+modelName+'>' + modelName + 
							'</span></td><td colspan="1"><a href="javascript:void(0);" data-url="userReportEdit.jsp?model_id=' + modelId + 
							'&cycle_id=' + cycleId + '&userId=' + userId + '&userName=' + userName + 
							' &groupId=' + groupId +' &groupName=' + groupName + 
							' " class="green openF">编辑</a></td><td>' +
							'<a href="javascript:void(0);" userMailbox=' + userMailbox + '  userAccount=' + userName + '  userPhone=' + userPhone + '  userId=' + userId + ' userName=' + userNameone + ' groupName=' + groupName + ' groupId=' + groupId + 
							' singleLogin=' + singleLogin + ' loginPlatforn=' + loginPlatforn + ' infoManage=' + infoManage + ' userManage=' + userManage + ' class="revise">修改</a>' +
							'<a href="javascript:void(0);"  userId=' + userId + ' userName=' + userName + ' userType=' + userType + ' class="removeBtn">删除</a>' + '</td></tr>';
			}
			msgRight = "";
		}
		var strHead = "<tr class='th'><th width='130'>所属组织</th><th width='120'>账号</th><th width='120'>用户名称</th><th width='120'>电话号码</th><th width='160'>邮箱</th><th width='210' colspan='4'>信息方案权限</th><th width='210' colspan='4'>报告模板权限</th><th>操作</th></tr>";
		var strPage = "<tr class='pages'><td colspan='14'><div class='ui_page' id='pageArea'></div></td></tr>";
		if(objCount < 1) {
			$(".ktab").html(strHead + "<tr class='td' colspan='14'>加载失败，请刷新重试！<td></td></tr>");
		} else {
			$(".ktab").html(strHead + htmlList + strPage);
		}
	},
	//public load ajax
	"publicAjax": function(pIndex, numList, selectJsonData) {
		var _obj = $(".ktab");
		var url = basePath + "user/queryByParams.do?pageIndex=" + pIndex + "&pageSize=" + numList + '&vtimes=' + new Date().getTime();
		$.ajax({
			type: "POST",
			url: url,
			data: selectJsonData,
			error: function(request) {
				layer.msg("加载失败，请刷新重试！", 2, -1);
			},
			success: function(data) {
				if(data.returnCode == 10000) {
					if(data.returnData != null && data.returnData.length != 0) {
						q.loadData(data);
						paging.loadPage(data);
					} else if(data.returnData == null || data.returnData.length == 0) {
						$(".ktab").html("<tr class='th'><th width='130'>所属组织</th><th width='120'>账号</th><th width='120'>用户名称</th><th width='120'>电话号码</th><th width='160'>邮箱</th><th width='210' colspan='4'>信息方案权限</th><th width='210' colspan='4'>报告模板权限</th><th>操作</th></tr><tr class='td'><td colspan='14'>很遗憾，没有查询到相关数据！</td></tr>");
					}
				} else if(data.returnCode == 999994) {
					setUserTimeout(data);
				}
			},
			beforeSend: function() {
				var imgGif = "<p class='loadingGif'></p>";
				_obj.html(imgGif);
			}
		});
	},
}
//页面初始化
q.publicAjax(1, numList, selectJsonData);

/**
 * @param appP为选择app端的元素对象
 * @param webP为选择web端的元素对象
 * @param resultNum返回值
 * @returns {Number}
 */
function appWebPort(appP,webP,resultNum){
	if(appP.hasClass("checked") && !(webP.hasClass("checked"))){
		resultNum = 0;
	}else if(!(appP.hasClass("checked")) && webP.hasClass("checked")){
		resultNum = 1;
	}else if(appP.hasClass("checked") && webP.hasClass("checked")){
		resultNum = 2;
	}else{
		resultNum = null;
	}
	return resultNum
}

//添加
var savaData = {
	//数据处理
	"addFrom": function() {
		var loginPlatforn = null,infoManage = null,userManage = null;
		loginPlatforn = appWebPort($("#loginAppPort"),$("#loginWebPort"),loginPlatforn);
		infoManage = appWebPort($("#ifmAppPort"),$("#ifmWebPort"),infoManage);
		userManage = appWebPort($("#userAppPort"),$("#userWebPort"),userManage);
		var groupIdd = $("#groupIdd").val();
		var userAccount = $("#userAccountText").val().trim();
		var userPwd = $("#userPwdText").val();
		var userName = $("#userNameText").val();
		var userPhone = $("#userPhoneText").val();
		var userMailbox = $("#userMailboxText").val();
		var singlePortAdd = $("#singlePortAdd").val();
		var userType = null;
		if(loginPlatforn == 0){
			userType = 2;
		}else if(loginPlatforn == 1){
			userType = 3;
		}else if(loginPlatforn == 2){
			userType = 23;
		}
		var jsons = {
			"groupId": groupIdd,
			"userAccount": userAccount,
			"userPwd": userPwd,
			"userName": userName,
			"userPhone": userPhone,
			"userMailbox": userMailbox,
			"singleLogin": singlePortAdd,
			"userType": userType,
			"loginPlatforn":loginPlatforn,//0：APP端  1：web端 2：代表0和1
			"infoManage":infoManage,//0：APP端 1：web端 2：代表0和1
			"userManage":userManage//0：APP端   1：web端 2：代表0和1
		};
		return jsons;
	},
	
	//添加
	"postAjax": function() {
		$.ajax({
			type: 'POST',
			url: basePath + 'user/add.do',
			data: savaData.addFrom(),
			success: function(data) {
				if(data.returnCode == 10000) {
					layer.msg(data.returnMessage, 1, 10);
					setTimeout(function(){
						try{
							$('#selectAll').trigger('click');
						}catch(e){}
					},1000);
					layer.close(pageUserAdd);
//					q.publicAjax(1, numList, "");
					$("#addkeyGroName").attr("value","");
					$("#addkeyGroName").text("");
					$(".clearFormInput").val("");
					$("#singlePortAdd").val("1");
					$("#singlePortAddText").text("是");
					$(".boxPosition").removeClass("checked");
				} else if(data.returnCode == 999994) {
					setUserTimeout(data);
				} else {
					layer.msg(data.returnMessage, 2, -1);
					avoidDup =true;
				}
			},
			error: function(message) {
				layer.msg(message, 2, -1);
			}
		});
	}
}

//点击新增
$("#addParameterArea").validationEngine({
	"focusFirstField": true,
	"maxErrorsPerField": "1"
});
var avoidDup = true;
$("#addParameterBtn").live("click", function() {
	if(avoidDup==false){
		return false;
	}
	var comsss = $('#groupIdd').val();
	if(!comsss) {
		layer.msg("请选择所属组织 !", 2, -1);
		avoidDup = true;
		return false;
	}
	var isSuccess = $('#addParameterArea').validationEngine('validate');
	if(!isSuccess){
		avoidDup = true;
		return false;
	}
	var isUserType = $("#loginAppPort").hasClass("checked")||$("#loginWebPort").hasClass("checked");
	if(!isUserType){
		layer.msg("请至少选择一项登录平台 !", 2, -1);
		avoidDup = true;
		return false;
	}
	avoidDup = false;
	savaData.postAjax();
});

//编辑事件
$("#editParameterArea").validationEngine({
	"focusFirstField": true,
	"maxErrorsPerField": "1"
});
$("#updateParameterBtn").live("click", function() {
	var isUserType = $("#loginAppPortEdit").hasClass("checked")||$("#loginWebPortEdit").hasClass("checked");
	if(!isUserType){
		layer.msg("请至少选择一项登录平台 !", 2, -1);
		return false;
	}
	var isSuccess = $('#editParameterArea').validationEngine('validate');
	if(isSuccess == true) {
		edit.postEditAjax();
	}
});

var edit = {
	//用户编辑数据处理
	"editFrom": function() {
		var userGropId = $("#userGroupId").val();
		var userId = $("#userId").val();
		var userAccount = $("#userAccountEditText").val().trim();
		//作为url进行编码
		var userName = $("#userNameEditText").val();
		userName = encodeURI(userName);
/*		if($("#userPwdEditText").val()!=""){
			var userPwd = $("#userPwdEditText").val();
		}else{
			var userPwd = '******';
		}*/
		var userPwd = $("#userPwdEditText").val();
		var userPhone = $("#userPhoneEditText").val();
		var userMailbox = $("#userMailboxEditText").val();
		var singlePortEdit = $("#singlePortEdit").val();
		var loginPlatforn = null,infoManage = null,userManage = null;
		loginPlatforn = appWebPort($("#loginAppPortEdit"),$("#loginWebPortEdit"),loginPlatforn);
		infoManage = appWebPort($("#ifmAppPortEdit"),$("#ifmWebPortEdit"),infoManage);
		userManage = appWebPort($("#userAppPortEdit"),$("#userWebPortEdit"),userManage);
		var userType = null;
		if(loginPlatforn == 0){
			userType = 2;
		}else if(loginPlatforn == 1){
			userType = 3;
		}else if(loginPlatforn == 2){
			userType = 23;
		}
		var jsons = {
			"groupId2": $("#userGroupIdS").val(),	
			"groupId": userGropId,
			"userAccount": userAccount,
			"userName": userName,
			"userPwd": userPwd,
			"userPhone": userPhone,
			"userMailbox": userMailbox,
			"singleLogin": singlePortEdit,
			"userType": userType,
			"userId": userId,
			"loginPlatforn":loginPlatforn,
			"infoManage":infoManage,
			"userManage":userManage
		};
		
		return jsons;
	},
	//用户编辑接口
	"postEditAjax": function() {
		var url = basePath + "user/modify";
		$.ajax({
			type: 'GET',
			url: url,
			data: edit.editFrom(),
			success: function(data) {
				if(data.returnCode == 10000) {
					layer.msg(data.returnMessage, 1, 10);
					$("#userPwdEditText").val("");
					layer.close(pageUserEdit);
					q.publicAjax(curPage, numList, selectJsonData);
				} else if(data.returnCode == 999994) {
					setUserTimeout(data);
				} else {
					layer.msg(data.returnMessage, 2, -1);
				}
			},
			error: function(message) {
				layer.msg(message, 2, -1);
			}
		});
	}
}

//点击删除
$(".removeBtn").live("click", function() {
	var userName = $(this).attr("userName").trim();
	var userId = parseInt($(this).attr("userId"));
	var userType = $(this).attr("userType").trim();
	var objDel = {
		"userName": userName,
		"userId": userId,
		"userType": userType,
	};
	$.layer({
		title: "温馨提示：",
		shade: [0],
		area: ['230', 'auto'],
		dialog: {
			msg: '确定删除吗？',
			btns: 2,
			type: -1,
			btn: ['确定', '取消'],
			yes: function() {
				removes.removeAjax(objDel);
			},
			no: function() {}
		}
	});
});
var removes = {
	"removeAjax": function(objDel) {
		$.ajax({
			type: 'POST',
			url: basePath + 'user/deleteUser.do',
			data: objDel,
			success: function(data) {
				if(data.returnCode == 10000) {
					layer.msg(data.returnMessage, 1, 10);
					if($("#curLen").val()==2&&curPage>1){
						curPage = curPage-1;
					}
					q.publicAjax(curPage, numList, selectJsonData);
				} else if(data.returnCode == 999994) {
					setUserTimeout(data);
				} else {
					layer.msg(data.returnMessage, 1, -1);
				}
			},
			error: function(message) {
				layer.msg("删除数据失败！<br>" + message, 2, -1);
			}
		});
	}
}

//点击查询
$("#selectAll").live("click", function() {
	curPage = 1;
	qDataFun(curPage);
});
$('.enterSearch').keydown(function(e) {
	if(e.keyCode == 13) {
		curPage = 1;
		qDataFun(1);
	}
});

//点击触发换页的按钮
$("#pageArea .pNumBtn  a").live("click", function() {
	curPage = parseInt($(this).attr("toPage"));
	qDataFun(curPage);
});

//点击触发分批显示的按钮
$("#pageArea .columnsPage a").live("click", function() {
	numList = parseInt($(this).text());
	curPage = 1;
	qDataFun(curPage);
	subPage = $(this).index();
});
//跳转
$("#pageArea .gopg .btn").live("click", function() {
	curPage = parseInt($("#pageArea .gopg .txt").val());
	//判断输入的页数是否大于最大的页数
	if(curPage>countPage){
		curPage=countPage;
	}
	if(curPage>0){
		qDataFun(curPage);
	}
});

function qDataFun(curPages) {
	var sleGroupId = $("#sleGroupId").val().trim();
	var sleGroupName = $("#sleGroupName").val().trim();
	if(sleGroupName == "") {
		sleGroupId = "";
	}
	var userNameSearch = $("#userNameSearch").val().trim();
	var userNameoneSearch = $("#userNameoneSearch").val().trim();
	var userPhoneSearch = $("#userPhoneSearch").val().trim();
	var userMailboxSearch = $("#userMailboxSearch").val().trim();
	selectJsondata = null;
	if(sleGroupId !=""||userNameSearch !=""||userNameoneSearch!=""||userPhoneSearch!=""||userMailboxSearch!=""){
		selectJsonData = {
			"group": sleGroupId,
			"account": userNameSearch,
			"name":userNameoneSearch,
			"phone":userPhoneSearch,
			"mailbox":userMailboxSearch
		};
		q.publicAjax(curPages, numList, selectJsonData);
	}else{
		q.publicAjax(curPages, numList, "");
	}
};

//组织
$("#sleGroupName").live("keyup", function() {
	var GroName = $(this).val();
	qApp.qOrgAffListAjax("#selGroup", GroName);
});

$("#grouptag .ui_s_bk a").live("click", function() {
	var groupIdd = $(this).attr("ids");
	$("#sleGroupId").attr("value", groupIdd);
	var names = $(this).text();
//	console.log(names + "-" + $(this));
	$(this).parent().siblings(".ui_s_t").attr("value", names);
});
$("#sleGroupName").live("click", function() {
	qApp.qOrgAffListAjax("#selGroup", "");
	$("#selGroup").css("z-index", 100);
	$("#selGroup").show();
});

//新增--组织
$("#addkeyGroName").live("keyup", function() {
	var GroName = $(this).val();
	qApp.qOrgAffListAjax("#allOrgListAdd", GroName);
});
$("#regionSelectAdd .ui_select .ui_s_bk a").live("click", function() {
	var groupIdd = $(this).attr("ids");
	$("#groupIdd").attr("value", groupIdd);
	var names = $(this).text();
	$(this).parent().siblings(".ui_s_t").attr("value", names);
});
$("#addkeyGroName").live("click", function() {
	qApp.qOrgAffListAjax("#allOrgListAdd", "");
	$("#allOrgListAdd").css("z-index", 100);
	$("#allOrgListAdd").show();
});
//新增--单点登录
$(".selectListObjAdd a").live("click", function() {
	var singlePortAdd = $(this).attr("value");
	$("#singlePortAdd").attr("value", singlePortAdd);
});

//修改--组织
$("#eidkeyGroName").live("keyup", function() {
	var GroName = $(this).val();
	qApp.qOrgAffListAjax("#allOrgListEid", GroName);
	//	$("#allOrgListEid").css("z-index", 100);
	//	$("#allOrgListEid").show();
});
$("#regionSelectEid .ui_select .ui_s_bk a").live("click", function() {
	var groupIdd = $(this).attr("ids");
	$("#userGroupId").attr("value", groupIdd);
	var names = $(this).text();
	$(this).parent().siblings(".ui_s_t").attr("value", names);
	//	$("#allOrgListEid").css("z-index", 0);
	//	$("#allOrgListEid").hide("slow");
});
$("#eidkeyGroName").live("click", function() {
	qApp.qOrgAffListAjax("#allOrgListEid", "");
	$("#allOrgListEid").css("z-index", 100);
	$("#allOrgListEid").show();
});
//修改--单点登录
$(".selectListObjEdit a").live("click", function() {
	var singlePortEdit = $(this).attr("value");
	$("#singlePortEdit").attr("value", singlePortEdit);
});

var qApp = {
	'qOrgAffListAjax': function(_obj, name) {
		var htmls = "";
		if($(_obj).selector == '#selGroup') {
			htmls = '<a href="javascript:void(0);" ids="">全部</a>';
		}
		$.ajax({
			type: "POST",
			url: basePath + "group/selectAllName",
			data: {
				'gName': name,
			},
			success: function(data) {
				if(data.returnCode == 10000) {
					var orgLen = data.returnData.length;
					for(i = 0; i < orgLen; i++) {
						htmls = htmls + "<a href='javascript:void(0)' ids=" + data.returnData[i].groupId + " >" + data.returnData[i].groupName + "</a>";
					}
					$(_obj).html(htmls);
				} else if(data.returnCode == 999994) {
					setUserTimeout(data);
				} else {
					layer.msg("操作失败，请重试！", 2, -1);
				}
			},
			error: function(message) {
				layer.msg("操作失败，请重试！", 2, -1);
			}
		});
	}
}

$(".infoLlist .ui_checkbox").live("click", function() {
	if($(this).hasClass("checked")) {
		$(this).removeClass("checked");
	} else {
		$(this).addClass("checked");
	}
});

$('.ui_select').each(function() {
	var _ = $(this),
		_a = _.find('.ui_s_t'),
		_c = _.find('.ui_s_bk'),
		_ca = _c.find('a');
	_a.live('click', function() {
		_c.slideToggle(200, "easeInSine");
	});
	_ca.live('click', function() {
		$(this).addClass('cur').siblings().removeClass('cur');
		_a.text($(this).text());
		$("#addIsSign").val($(this).attr("type"));
		_c.slideToggle(200, "easeInSine");
	});
	_c.live('mouseleave', function() {
		_c.stop(false, true).slideUp(200, "easeInSine");
	});
});

$('.ui_select').live('keyup', function(e) {
	var _ = $(this),
		b = _.find('.ui_s_bk'),
		di = 27;
	_.focus();
	e = e || window.event;
	var indx = b.find('a.cur').index() || 0;
	if(e.keyCode == 40) {
		var aindx = indx + 1,
			sct;
		if(rindx >= b.find('a').length) {
			rindx = b.find('a').length;
		}
		b.find('a').eq(aindx).addClass('cur').siblings('a').removeClass('cur');
		sct = aindx * di > 180 ? aindx * di - 80 : 0;
		b.scrollTop(sct);
	} else if(e.keyCode == 38) {
		var rindx = indx - 1,
			sct;
		sct = aindx * di > 100 ? aindx * di : 0;
		if(rindx <= 0) {
			rindx = 0;
		}
		b.find('a').eq(rindx).addClass('cur').siblings('a').removeClass('cur');
		sct = rindx * di > 180 ? rindx * di - 80 : 0;
		b.scrollTop(sct);
	} else if(e.keyCode == 13) {
		b.find('a.cur').trigger('click');
		_.blur();
		_.find('.ui_s_t').blur();
	}
	return false;
});
